import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:sale/utils/auth_state.dart';
import 'package:sale/login_page.dart';

class AuthWrapper extends StatelessWidget {
  final Widget child;

  const AuthWrapper({
    super.key,
    required this.child,
  });

  @override
  Widget build(BuildContext context) {
    return Consumer<AuthState>(
      builder: (context, authState, _) {
        if (!authState.isLoggedIn) {
          return const LoginPage();
        }
        return child;
      },
    );
  }
}
